
	const state={
		// cart:JSON.parse(uni.getStorageSync("cart")|| "[]")
		cart:uni.getStorageSync("cart")|| [],
		address:uni.getStorageSync("address")|| {},
		userInfo:uni.getStorageSync("userInfo")||{},
		skip:uni.getStorageSync("skip")||{},
		
	}
	const mutations={
		redirectInfo(state,data){
			console.log(data)
			state.skip=data
		},
		removeMU(state){
			state.address={}
			state.userInfo={}
		},
		pssInfo(state,value){
			state.userInfo=value
		},
		addToCart(state,goods)
		{
		  const findResult=state.cart.find(x=>x.goods_id===goods.goods_id)
		
		if(!findResult){
			
			state.cart.push(goods)
		}else{
			findResult.goods_count++
		}
	 },
	 REVISE(state,goods){
		 state.cart.forEach(x=>{
			 if(x.goods_id===goods.goods_id){
				
				x.goods_state=goods.goods_state
				
			 }
		 })
		 
		
	 },
	 passNum(state,goods){
		
		 state.cart.forEach(x=>{
		 			 if(x.goods_id===goods.goods_id){
		 				x.goods_count=goods.goods_count		
		 			 }
		 })
		  
	 },
	 removeID(state,goods_id){ 
		 state.cart=state.cart.filter(x=>x.goods_id!==goods_id)
		 
	 },
	 address(state,address){
		state.address=address
	 }
	}
	const getters={
        total(state){
			let c = 0
			state.cart.forEach(x=>c+=x.goods_count)
			return c
		}
	}

export default{
	getters,
	mutations,
	state
}